//----------------------------------------------------------------------------
//  (c) 2007    Sergio Lora Garcia
//----------------------------------------------------------------------------
#include "gui/nguiwindowslider.h"

static void n_sethiderect(void* slf, nCmd* cmd);
static void n_gethiderect(void* slf, nCmd* cmd);
static void n_setshowrect(void* slf, nCmd* cmd);
static void n_getshowrect(void* slf, nCmd* cmd);
static void n_setsliderate(void* slf, nCmd* cmd);
//----------------------------------------------------------------------------
/**
    @scriptclass
    nguiwindowslider

    @cppclass
    nguiwindowslider
    
    @superclass
    nguiwindow

    @classinfo
    a brief description of the class
*/
void
n_initcmds(nClass* clazz)
{
    clazz->BeginCmds();
    clazz->AddCmd("v_sethiderect_ffff",  'SHRE', n_sethiderect);
    clazz->AddCmd("ffff_gethiderect_v",  'GHRE', n_gethiderect);
    clazz->AddCmd("v_setshowrect_ffff",  'SSRE', n_setshowrect);
    clazz->AddCmd("ffff_getshowrect_v",  'GSRE', n_getshowrect);
    clazz->AddCmd("v_setsliderate_f",  'SSLR', n_setsliderate);
    // clazz->AddCmd("v_Xxx_v", 'XXXX', n_Xxx);
    // etc.
    clazz->EndCmds();
}

//-----------------------------------------------------------------------------
/**
    @cmd
    sethiderect
    @input
    f(x0), f(x1), f(y0), f(y1)
    @output
    v
    @info
    Set the rectangle for the window hided.
*/
static void
n_sethiderect(void* slf, nCmd* cmd)
{
    nguiwindowslider* self = (nguiwindowslider*) slf;
    rectangle r;
    r.v0.x = cmd->In()->GetF();
    r.v1.x = cmd->In()->GetF();
    r.v0.y = cmd->In()->GetF();
    r.v1.y = cmd->In()->GetF();
		self->SetHideRect(r);
}

/**
    @cmd
    gethiderect
    @input
    v
    @output
    f(x0), f(x1), f(y0), f(y1)
    @info
    Set the rectangle for the window hided.
*/
static void
n_gethiderect(void* slf, nCmd* cmd)
{
    nguiwindowslider* self = (nguiwindowslider*) slf;
		const rectangle& r = self->GetHideRect();
    cmd->Out()->SetF(r.v0.x);
    cmd->Out()->SetF(r.v1.x);
    cmd->Out()->SetF(r.v0.y);
    cmd->Out()->SetF(r.v1.y);
}

//-----------------------------------------------------------------------------
/**
    @cmd
    setshowrect
    @input
    f(x0), f(x1), f(y0), f(y1)
    @output
    v
    @info
    Set the rectangle for the window showed.
*/
static void
n_setshowrect(void* slf, nCmd* cmd)
{
    nguiwindowslider* self = (nguiwindowslider*) slf;
    rectangle r;
    r.v0.x = cmd->In()->GetF();
    r.v1.x = cmd->In()->GetF();
    r.v0.y = cmd->In()->GetF();
    r.v1.y = cmd->In()->GetF();
		self->SetShowRect(r);
}

/**
    @cmd
    getshowrect
    @input
    v
    @output
    f(x0), f(x1), f(y0), f(y1)
    @info
    Set the rectangle for the window showed.
*/
static void
n_getshowrect(void* slf, nCmd* cmd)
{
    nguiwindowslider* self = (nguiwindowslider*) slf;
		const rectangle& r = self->GetShowRect();
    cmd->Out()->SetF(r.v0.x);
    cmd->Out()->SetF(r.v1.x);
    cmd->Out()->SetF(r.v0.y);
    cmd->Out()->SetF(r.v1.y);
}

/**
    @cmd
    setsliderate
    @input
    f(slideRate)
    @output
    v
    @info
    Set the slide rate for the slider window.
*/
static void
n_setsliderate(void* slf, nCmd* cmd)
{
	nguiwindowslider* self = (nguiwindowslider*) slf;
	float slideRate;
	slideRate = cmd->In()->GetF();
	self->SetSlideRate(slideRate);	
}
//----------------------------------------------------------------------------
// EOF
//----------------------------------------------------------------------------
